var incomeChart = ring.create({
    constructor: function(plot) 
    {
        this.plot1 = plot;
    },
    plotChart: function(id, data)
    {
        var that = this;
        if (that.plot1) {
            that.plot1.destroy();
        }
        
        that.plot1 = $.jqplot(id, [data], {
            seriesDefaults:{
                pointLabels: { show: true },
                rendererOptions: {
                    varyBarColor: true
                }
            },
            series:[{renderer:$.jqplot.BarRenderer}],
//            axesDefaults: {
//                tickRenderer: $.jqplot.CanvasAxisTickRenderer ,
//                tickOptions: {
//                  fontSize: '10pt'
//                }
//            },
            axes: {
            yaxis: {
                //renderer: $.jqplot.CategoryAxisRenderer,
                tickOptions: {
                    formatString: '%.2f'
                } 
            },
            xaxis: {
                renderer: $.jqplot.CategoryAxisRenderer,
                tickOptions: {
                    formatString: '%.2f'
                  } 
              }
            }
        });
    },
    refresh: function(id, url_data) {
        var dateTo   = $('#select-month-to').val(); 
        var dateFrom = $('#select-month-from').val();   
        
        var that = this;
        
        $.ajax({
            url: url_data, 
            data: { date_to : dateTo, date_from : dateFrom},
            async: false, 
            success: function(result) 
            {
                 that.plotChart(id, result);
            }
        });
    }
});
